/**
 * 路由meta对象参数说明
 * meta: {
 *      title:          菜单栏及 tagsView 栏、菜单搜索名称（国际化）
 *      isLink：        是否超链接菜单，开启外链条件，`1、isLink: 链接地址不为空 2、isIframe:false`
 *      isHide：        是否隐藏此路由
 *      isKeepAlive：   是否缓存组件状态
 *      isAffix：       是否固定在 tagsView 栏上
 *      isIframe：      是否内嵌窗口，开启条件，`1、isIframe:true 2、isLink：链接地址不为空`
 *      roles：         当前路由权限标识，取角色管理。控制路由显示、隐藏。超级管理员：admin 普通角色：common
 *      icon：          菜单、tagsView 图标，阿里：加 `iconfont xxx`，fontawesome：加 `fa xxx`
 * }
 */

/**
 * 定义动态路由
 * @description 未开启 isRequestRoutes 为 true 时使用（前端控制路由），开启时第一个顶级 children 的路由将被替换成接口请求回来的路由数据
 * @description 各字段请查看 `/@/views/standard/system/menu/component/addMenu.vue 下的 ruleForm`
 * @returns 返回路由菜单数据
 */
import BaseRoute from './modules/index';
import { LayoutParentView } from '@/layout/routerView';
// import routerParent from '@/layout/routerView/parent.vue';

export const testRoutes = [
	{
		path: '/link',
		name: 'layoutLinkView',
		component: () => import('/@/layout/routerView/link.vue'),
		meta: {
			title: 'message.router.layoutLinkView',
			isLink: 'https://element-plus.gitee.io/#/zh-CN/component/installation',
			isHide: false,
			isKeepAlive: false,
			isAffix: false,
			isIframe: false,
			roles: ['admin'],
			icon: 'iconfont icon-caozuo-wailian',
		},
	},
];

export const dynamicRoutes = [
	{
		path: '/',
		name: '/',
		component: () => import('/@/layout/index.vue'),
		redirect: '/home',
		meta: {
			isKeepAlive: true,
		},
		children: [
			{
				path: '/home',
				name: 'home',
				component: () => import('@/views/standard/home/HomeView.vue'),
				meta: {
					title: '首页',
					isLink: '',
					isHide: false,
					isKeepAlive: true,
					isAffix: true,
					isIframe: false,
					roles: ['admin', 'common'],
					icon: 'iconfont icon-shouye',
				},
			},
			...BaseRoute,
		],
	},
];

/**
 * 定义404、401界面
 * @link 参考：https://next.router.vuejs.org/zh/guide/essentials/history-mode.html#netlify
 */
export const notFoundAndNoPower = [
	{
		path: '/:path(.*)*',
		name: 'notFound',
		component: () => import('/@/views/standard/error/404.vue'),
		meta: {
			title: '页面找不到',
			isHide: true,
		},
	},
	{
		path: '/401',
		name: 'noPower',
		component: () => import('/@/views/standard/error/401.vue'),
		meta: {
			title: '页面无权限',
			isHide: true,
		},
	},
];

// 不在布局中显示的页面，独立的页面
export const notLayoutRoutes = [
	{
		path: '/proj-yhs',
		name: 'ProjectYhsView',
		hidden: true,
		meta: {
			title: '项目一户式',
			isLink: '',
			isHide: true,
			isKeepAlive: false,
			isAffix: false,
			isIframe: false,
			roles: ['admin', 'common'],
			icon: 'iconfont icon-shouye',
		},
		component: () => import('@/views/previews/ProjectYhsView.vue'),
	},

	{
		path: '/previewFile/:id',
		name: 'previewFile',
		hidden: true,
		meta: {
				title: '文件预览',
				isLink: '',
				isHide: true,
				isKeepAlive: false,
				isAffix: false,
				isIframe: false,
				roles: ['admin', 'common'],
				icon: 'iconfont icon-caidan',
		},
		component: () => import('@/views/previews/FilePreview.vue'),
	},
	{
		path: '/system-check',
		name: 'LicenseInfoView',
		hidden: true,
		meta: {
			title: '注册信息',
			isLink: '',
			isHide: true,
			isKeepAlive: false,
			isAffix: false,
			isIframe: false,
			roles: ['admin', 'common'],
			icon: 'iconfont icon-shouye',
		},
		component: () => import('@/views/previews/LicenseInfoView.vue'),
	},
]

/**
 * 定义静态路由（默认路由）
 * 此路由不要动，前端添加路由的话，请在 `dynamicRoutes 数组` 中添加
 * @description 前端控制直接改 dynamicRoutes 中的路由，后端控制不需要修改，请求接口路由数据时，会覆盖 dynamicRoutes 第一个顶级 children 的内容（全屏，不包含 layout 中的路由出口）
 * @returns 返回路由菜单数据
 */
export const staticRoutes = [
	{
		path: '/login',
		name: 'login',
		component: () => import('@/views/standard/login/index.vue'),
		meta: {
			title: '登录',
		},
	},
	{
		path: '/oauth',
		name: 'oauth',
		hidden: true,
		name: 'oauth',
		component: LayoutParentView,
		meta: {
			icon: 'iconfont icon-shouye',
			roles: ['admin', 'common'],
			title: '登录授权',
			isLink: '',
			isHide: true,
			isAffix: false,
			isIframe: false,
			isKeepAlive: false,
		},
		redirect: '/oauth/view',
		children: [
			{
				path: '/oauth/view',
				name: 'OauthEntryView',
				component: () => import('@/views/standard/oauth/OauthEntryView.vue'),
				title: '登录授权跳转页',
				isLink: '',
				isHide: true,
				isAffix: false,
				isIframe: false,
				isKeepAlive: false,
			},
			{
				path: '/oauth/menu',
				name: 'OauthMenuView',
				component: () => import('@/views/standard/oauth/OauthMenuView.vue'),
				title: '登录授权跳转页',
				isLink: '',
				isHide: true,
				isAffix: false,
				isIframe: false,
				isKeepAlive: false,
			},
			{
				path: '/oauth/page',
				name: 'OauthPageView',
				component: () => import('@/views/standard/oauth/OauthPageView.vue'),
				title: '登录授权跳转页',
				isLink: '',
				isHide: true,
				isAffix: false,
				isIframe: false,
				isKeepAlive: false,
			},
		]
	},
	// 自定义的静态路由
	...notLayoutRoutes,
];
